/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.tags;

import alcatelparser.modules.AlgoUtil;
import alcatelparser.modules.BuilderFactory;
import alcatelparser.modules.I;

/**
 *
 * @author geniuz
 */
public class AdditionalINTag extends DefaultParserTag
{

    public AdditionalINTag()
    {
    }

    public final void parseTag(int ai[], int i)
    {
        _array = ai;
        _startParsePosition = i;
        setStandartLength(ai, i);/*
        if(isFullForm())
            BuilderFactory.getBuilder().writeTagContent(5, 0, getTagPropertiesValue(I.I(5947)), getTagIdentifyContent(i, i + 1));
        int j = AlgoUtil.getLength(ai, i + 1);
        int k = 0;
        _subPosition = i + 2;
        while(j > 0) 
        {
            int l = ai[_subPosition + k];
            int i1 = ai[_subPosition + k + 1];
            int j1 = l >> 5;
            int k1 = j1 << 5;
            l -= k1;
            switch(l)
            {
            case 3: // '\003'
                parseChargingInformation(_subPosition + k);
                break;

            case 4: // '\004'
                parseProvidedDestinationNumber(_subPosition + k, i1);
                break;

            case 6: // '\006'
                parserFreeFormatData(_subPosition + k, i1);
                break;

            case 7: // '\007'
                parseChargeRateModulator(_subPosition + k, i1);
                break;
            }
            j -= 2 + i1;
            k += 2 + i1;
        }*/
    }

    private void parseChargeRateModulator(int i, int j)
    {
        if(isFullForm())
        {
            String s = (new StringBuilder()).append(getTagIdentifyContent(i, i + 1)).append(toHex(_array[i + 2])).toString();
            BuilderFactory.getBuilder().writeTagContent(6, 0, getTagPropertiesValue(I.I(3770)), s);
        }
    }

    private void parserFreeFormatData(int i, int j)
    {
        int k = _array[i + 3];
        String s = getHexStringContent(i + 4, k);
        if(isFullForm())
            BuilderFactory.getBuilder().writeTagContent(6, 0, getTagPropertiesValue(I.I(3724)), (new StringBuilder()).append(getTagIdentifyContent(i, i + 1)).append(s).toString());
        else
        if(isTagChecked(I.I(3707)))
            BuilderFactory.getBuilder().writeTagContent(1, 0, getReducedTagPropertiesValue(I.I(3724)), s);
    }

    private void parseProvidedDestinationNumber(int i, int j)
    {
        if(isFullForm())
        {
            String s = (new StringBuilder()).append(getTagIdentifyContent(i, i + 1)).append(getHexStringContent(i + 2, j)).toString();
            BuilderFactory.getBuilder().writeTagContent(6, 0, getTagPropertiesValue(I.I(3672)), s);
            PhoneNumberDecoratorTag phonenumberdecoratortag = new PhoneNumberDecoratorTag();
            phonenumberdecoratortag.setReducedTagName(getTagPropertiesValue(I.I(3672)));
            phonenumberdecoratortag.decorateTag(_array, i, true, j);
        } else
        if(isTagChecked(I.I(3644)))
        {
            String s1 = getReducedTagPropertiesValue(I.I(3672));
            if(isFieldsDecoding())
            {
                PhoneNumberDecoratorTag phonenumberdecoratortag1 = new PhoneNumberDecoratorTag();
                phonenumberdecoratortag1.setReducedTagName(s1);
                phonenumberdecoratortag1.decorateTag(_array, i, true, j);
            } else
            {
                BuilderFactory.getBuilder().writeTagContent(1, 0, s1, getHexStringContent(i + 2, j));
            }
        }
    }

    private void parseChargingInformation(int i)
    {
        ChargingInformationTag charginginformationtag = new ChargingInformationTag();
        charginginformationtag.setIsAdditionalType(true);
        charginginformationtag.setShift(3);
        charginginformationtag.setTagIdentifyContent(getTagPropertiesValue(I.I(5930)));
        charginginformationtag.parseTag(_array, i);
    }

    private int _subPosition;
    private int _subLength;
}
